﻿using CSharpDevTools.Core;
using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpDevTools.ViewModels
{
    internal class Base64ControlViewModel : EncodeBaseViewModel
    {
        protected override void Encode()
        {
            if (string.IsNullOrEmpty(this.OriginalData))
            {
                MessageBox.Error("原始数据不能为空！", "错误");
                return;
            }

            this.EncodedData = Base64Helper.ToBase64(this.OriginalData);
        }

        protected override void Decode()
        {
            if (string.IsNullOrEmpty(this.EncodedData))
            {
                MessageBox.Error("编码后数据不能为空！", "错误");
                return;
            }

            this.OriginalData = Base64Helper.FromBase64String(this.EncodedData);
        }
    }
}
